#include<bits/stdc++.h>
using namespace std;
int t,n,m,L,vv;
const int M=1e5+5;
const int N=1e6+6;
int d[M],v[M],a[M],l,r,p[M],ans,z,z1;
double v1,u1,u2,u;
bool b,ip;
vector<int>g[M];
int vis[M];
void dfs(int id,int ss,int s2)
{
    if(ss==z)
    {
        ans=max(ans,s2);
        return ;
    }
    if(id==m+1) return ;
    dfs(id+1,ss,s2+1);
    z1=0;
    for(int i=0;i<g[id].size();i++)
    {
        vis[g[id][i]]++;
        if(vis[g[id][i]]==1) z1++;
    }
    dfs(id+1,ss+z1,s2);
    for(int i=0;i<g[id].size();i++)
    {
        vis[g[id][i]]--;
    }
    return ;
}
int main()
{
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    scanf("%d",&t);
    while(t--)
    {
        z=0;
        ans=0;
        scanf("%d%d%d%d",&n,&m,&L,&vv);
        for(int i=1;i<=n;i++)
        {
            vis[i]=0;
            scanf("%d%d%d",&d[i],&v[i],&a[i]);
        }
        for(int i=1;i<=m;i++)
        {
            scanf("%d",&p[i]);
            g[i].clear();
        }
        for(int i=1;i<=n;i++)
        {
            b=true;
            if(a[i]==0)
            {
                if(v[i]>vv)
                {
                    l=d[i];
                    r=L;
                }
                else b=false;
            }
            else if(a[i]>0)
            {
                if(v[i]>vv)
                {
                    l=d[i];
                    r=L;
                }
                else
                {
                    v1=sqrt(2*a[i]*(L-d[i])+v[i]*v[i]);
                    if(v1<=double(vv)) b=false;
                    else
                    {
                        u1=vv*vv-v[i]*v[i];
                        u2=2*a[i];
                        u=u1/u2+d[i];
                        l=ceil(u);
                        if(u==(double)l) l++;
                        r=L;
                    }
                }
            }
            else
            {
                if(v[i]<=vv) b=false;
                else
                {
                    l=d[i];
                    u1=v[i]*v[i]-vv*vv;
                    u2=(-2)*a[i];
                    u=u1/u2+d[i];
                    if(u>L) r=L;
                    else
                    {
                        r=ceil(u);
                        if((double)r==u) r--;
                    }
                }
            }
            if(b==false) continue;
            ip=false;
            for(int j=1;j<=m;j++)
            {
                if(p[j]>=l&&p[j]<=r)
                {
                    g[j].push_back(i);
                    ip=true;
                }
            }
            if(ip==true) z++;
        }
        dfs(1,0,0);
        printf("%d %d\n",z,ans);
    }
    return 0;
}
